package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Courses1;
import com.ruoyi.system.service.ICourses1Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 成绩表1Controller
 * 
 * @author ruoyi
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/system/courses1")
public class Courses1Controller extends BaseController
{
    @Autowired
    private ICourses1Service courses1Service;

    /**
     * 查询成绩表1列表
     */
    @PreAuthorize("@ss.hasPermi('system:courses1:list')")
    @GetMapping("/list")
    public TableDataInfo list(Courses1 courses1)
    {
        startPage();
        List<Courses1> list = courses1Service.selectCourses1List(courses1);
        return getDataTable(list);
    }

    /**
     * 导出成绩表1列表
     */
    @PreAuthorize("@ss.hasPermi('system:courses1:export')")
    @Log(title = "成绩表1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Courses1 courses1)
    {
        List<Courses1> list = courses1Service.selectCourses1List(courses1);
        ExcelUtil<Courses1> util = new ExcelUtil<Courses1>(Courses1.class);
        util.exportExcel(response, list, "成绩表1数据");
    }

    /**
     * 获取成绩表1详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:courses1:query')")
    @GetMapping(value = "/{courseId}")
    public AjaxResult getInfo(@PathVariable("courseId") Long courseId)
    {
        return success(courses1Service.selectCourses1ByCourseId(courseId));
    }

    /**
     * 新增成绩表1
     */
    @PreAuthorize("@ss.hasPermi('system:courses1:add')")
    @Log(title = "成绩表1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Courses1 courses1)
    {
        return toAjax(courses1Service.insertCourses1(courses1));
    }

    /**
     * 修改成绩表1
     */
    @PreAuthorize("@ss.hasPermi('system:courses1:edit')")
    @Log(title = "成绩表1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Courses1 courses1)
    {
        return toAjax(courses1Service.updateCourses1(courses1));
    }

    /**
     * 删除成绩表1
     */
    @PreAuthorize("@ss.hasPermi('system:courses1:remove')")
    @Log(title = "成绩表1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseIds}")
    public AjaxResult remove(@PathVariable Long[] courseIds)
    {
        return toAjax(courses1Service.deleteCourses1ByCourseIds(courseIds));
    }
}
